package com.aps.server.kpi.controller;

import com.aps.common.entity.Result;
import com.aps.server.entity.ApsOperation;
import com.aps.server.service.ApsOperationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工序表 前端控制器
 * 
 * @author aps
 * @since 2024-01-01
 */
@Slf4j
@Tag(name = "KPI接口", description = "KPI 分析相关接口")
@RestController
@RequestMapping("/api/aps/kpi")
@CrossOrigin
public class ApsKpiController {

    @Autowired
    private ApsOperationService apsOperationService;

    @Operation(summary = "删除工序", description = "根据ID删除工序")
    @GetMapping("/cal/{id}")
    public Object delete(@PathVariable String id) {
        try {
            boolean success = apsOperationService.deleteOperation(id);
            if (success) {
                return Result.success("工序信息删除成功");
            } else {
                return Result.error(400, "工序信息删除失败");
            }
        } catch (Exception e) {
            log.error("删除工序信息失败", e);
            return Result.error(500, "删除工序信息失败: " + e.getMessage());
        }
    }
}
